from flask_script import Manager, Command
from flask_migrate import Migrate, MigrateCommand

from hzb import create_app
from hzb.config import DevConfig
from hzb.database import db
from sqlalchemy import Column, Integer, VARCHAR, Text
from sqlalchemy.dialects.mysql import TINYINT

app = create_app(db, new_config=DevConfig)
manager = Manager(app)
migrate = Migrate(app, db)


class CreateDB(Command):
    def run(self):
        db.create_all()

manager.add_command('create_all_db', CreateDB())
manager.add_command('db', MigrateCommand)

if __name__ == "__main__":
    # 局域网发布,命令行运行——python manager.py runserver --host 0.0.0.0
    manager.run()
